const verifyQueryAllParams = async (ctx, next) => {
  const requsetObj = {};
  if (ctx.request.body) {
    const { status, tagId, title, typeId, page, size,isBanner,collectIds } = ctx.request.body;
    if (status != null) {
      requsetObj.status = status;
    }
    if(collectIds) {
      requsetObj.collectIds = collectIds;
    }
    if (tagId !== null) {
      requsetObj.tagId = tagId;
    }
    if(isBanner) {
      requsetObj.isBanner = isBanner;
    }
    if (title) {
      requsetObj.title = title;
    }
    if (typeId !== null) {
      requsetObj.typeId = typeId;
    }
    if (page) {
      requsetObj.page = page;
    } else {
      requsetObj.page = 1;
    }
    if (size) {
      requsetObj.size = size;
    } else {
      requsetObj.size = 40;
    }
  } else {
    requsetObj.page = 1;
    requsetObj.size = 40;
  }
  ctx.request.body = requsetObj;
  await next();
};

module.exports = { verifyQueryAllParams };
